from flask import Blueprint,jsonify,request
from db import db1
import datetime
# from app import create_app
# from tasks import make_celery
# flask_app = create_app()
# celery = make_celery(flask_app)

bp_manage = Blueprint('manage',__name__)



@bp_manage.route('/managelist')
def managelist():
    sql = "select * from customer_manager"
    res = db1.find_all(sql)
    return jsonify({"code":200,'list':res})

@bp_manage.route('/resourcelist11')
def resourcelist():
    sql = "select * from reg_form"
    print(sql)
    res = db1.find_all(sql)
    return jsonify({"code":200,'list':res})




import time
@bp_manage.route('/customer_reg',methods=['POST'])
def customer_reg():
    data = request.json
    now = int(time.time())
    sql = "insert into customer(name,tmoney,company_name,manager_id,refromid,addtime) values('%s',%d,'%s',%d,%d,%d)"\
          %(data['name'],int(data['money']),data['company'],int(data['manager_id']),int(data['refromid']),now)

    db1.update(sql)
    return jsonify({"code":200})



















